<template>
    <div>
    <el-upload
            class="upload-demo"
            :action="serviceUrl"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-remove="beforeRemove"
            :on-success="handleSuccess"
            :http-request="uploadRequest"
            multiple
            :limit="3"
            :on-exceed="handleExceed"
            accept=".jpg,.jpeg,.png,.gif,.bmp,.pdf,.JPG,.JPEG,.PBG,.GIF,.BMP,.PDF,.dmg"
            :file-list="fileList">
        <el-button size="small" type="primary">点击上传</el-button>
    </el-upload>

        <img :src="imgUrl">
    </div>



</template>
<script>
    import {uploadImg} from "@/api/file/upload";
    export default {
        data() {
            return {
                fileList: [],
                serviceUrl: "",
                imgUrl:""
            };
        },
        methods: {
            handleRemove(file, fileList) {
            },
            handlePreview(file) {
                this.imgUrl=this.$itsoftUI.config.fileServer+file.response.data
            },
            handleExceed(files, fileList) {
                this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${file.name}？`);
            },
            handleSuccess(response, file, fileList) {

            },
            uploadRequest(option) {
                uploadImg(option)
            }
        }
    }
</script>

<style scoped>

</style>
